package com.xx.pmis.services.implementations;

import java.util.List;

import com.xx.pmis.model.Book;
import com.xx.pmis.persistence.dao.BookDAO;
import com.xx.pmis.services.BookService;

public class BookServiceImpl implements BookService {
	BookDAO bookDAO = null;

	public BookServiceImpl(BookDAO bookDAO) {
		super();
		this.bookDAO = bookDAO;
	}

	public void saveOrUpdateBook(Book book) throws Exception {
		bookDAO.saveOrUpdate(book);
	}

	public void saveBook(Book book) throws Exception {
		bookDAO.save(book);
	}

	public void deleteBook(Book book) throws Exception {
		bookDAO.delete(book);
	}

	public Book getBookByBookID(String bookID) throws Exception {
		Book book = bookDAO.getBookByBookID(bookID);
		return book;
	}

	public List<Book> getAllBookByCondition(String hql) throws Exception {
		List<Book> books = bookDAO.getAllBookByCondition(hql);
		return books;
	}

	public List<Book> getAllBookByConditionByPage(String hql, int currentPage, int lineSize) throws Exception {
		List<Book> books = bookDAO.getAllBookByConditionByPage(hql, currentPage, lineSize);
		return books;
	}

	public int getCountOfBookByCondition(String hql) throws Exception {
		return bookDAO.getAllBookByCondition(hql).size();
	}

}
